// ========================================
// API 接口统一导出
// ========================================

// 用户认证和管理相关API
export * from './user.js'

// 智能问答相关API
export * from './qa.js'

// AI专用API接口
export * from './ai.js'

// 知识库和文档管理相关API
export * from './knowledgebase.js'

// 历史记录管理相关API
export * from './history.js'

// ========================================
// API 使用示例
// ========================================

/*
// 1. 用户登录
import { login, saveToken } from '@/api/index.js'

const handleLogin = async () => {
  try {
    const result = await login({
      Username: 'admin',
      Password: 'password123'
    })
    
    if (result.code === 200) {
      saveToken(result.data)
      console.log('登录成功')
    }
  } catch (error) {
    console.error('登录失败:', error)
  }
}

// 2. 智能问答
import { generateAnswer, getModelConfig } from '@/api/index.js'

const handleQuestion = async (question) => {
  try {
    // 使用DeepSeek推理模型
    const config = getModelConfig('deepseek-reasoner')
    const result = await generateAnswer({
      question,
      ...config
    })
    
    console.log('AI回答:', result.data.answer)
  } catch (error) {
    console.error('问答失败:', error)
  }
}

// 3. 知识库问答
import { generateAnswer, createKnowledgeBase, uploadDocument } from '@/api/index.js'

const setupKnowledgeBase = async () => {
  try {
    // 创建知识库
    const kbResult = await createKnowledgeBase({
      knowledgeBaseName: '技术文档库',
      knowledgeBaseDescription: '存储技术相关文档'
    })
    
    const knowledgeBaseId = kbResult.data.knowledgeBaseId
    
    // 上传文档
    await uploadDocument({
      filePath: '/path/to/document.pdf',
      documentTitle: '技术文档',
      knowledgeBaseId
    })
    
    // 基于知识库问答
    const answer = await generateAnswer({
      question: '什么是RAG技术？',
      knowledgeBaseId,
      model: 'deepseek-chat'
    })
    
    console.log('基于知识库的回答:', answer.data.answer)
  } catch (error) {
    console.error('知识库设置失败:', error)
  }
}

// 4. 历史记录查询
import { getUserConversations, getLast7DaysRange } from '@/api/index.js'

const getRecentHistory = async () => {
  try {
    const dateRange = getLast7DaysRange()
    const result = await getUserConversations({
      ...dateRange,
      page: 1,
      pageSize: 20
    })
    
    console.log('最近7天的对话记录:', result.data)
  } catch (error) {
    console.error('获取历史记录失败:', error)
  }
}

// 5. 向量检索
import { retrieveChunks, generateEmbedding } from '@/api/index.js'

const searchSimilarContent = async (query) => {
  try {
    // 检索相关文档块
    const chunks = await retrieveChunks(query, 5)
    console.log('相关文档块:', chunks.data)
    
    // 生成文本向量
    const embedding = await generateEmbedding(query)
    console.log('文本向量:', embedding.data)
  } catch (error) {
    console.error('向量检索失败:', error)
  }
}
*/

// ========================================
// 常用配置
// ========================================

// 模型配置预设
export const MODEL_PRESETS = {
  // 通用对话
  CHAT: {
    model: 'deepseek-chat',
    maxTokens: 1500,
    temperature: 0.7
  },
  
  // 深度推理
  REASONING: {
    model: 'deepseek-reasoner',
    maxTokens: 2000,
    temperature: 0.4
  },
  
  // 星火对话
  XUNFEI_CHAT: {
    model: 'x1',
    xunfeiVersion: 'v2',
    xunfeiMode: 'chat',
    maxTokens: 1500,
    temperature: 0.7
  },
  
  // 星火推理
  XUNFEI_REASONING: {
    model: 'x1',
    xunfeiVersion: 'v2',
    xunfeiMode: 'reasoner',
    maxTokens: 2000,
    temperature: 0.5
  }
}

// 文件类型支持
export const SUPPORTED_FILE_TYPES = {
  'application/pdf': '.pdf',
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '.docx',
  'application/msword': '.doc',
  'text/plain': '.txt',
  'text/markdown': '.md'
}

// 文档状态
export const DOCUMENT_STATUS = {
  PENDING: 'pending',
  PROCESSING: 'processing',
  COMPLETED: 'completed',
  FAILED: 'failed'
}

// 模型类型
export const MODEL_TYPES = {
  DEEPSEEK_CHAT: 'deepseek-chat',
  DEEPSEEK_REASONER: 'deepseek-reasoner',
  XUNFEI_CHAT: 'xunfei-chat',
  XUNFEI_REASONER: 'xunfei-reasoner'
} 